package com.gb.push.controller;

import com.gb.push.handler.SenderActivity;
import com.gb.push.param.MessageParam;
import com.gb.push.param.SendRequest;
import com.gb.push.service.PushSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: wgs
 * @Date 2022/3/15 09:02
 * @Classname PushController
 * @Description
 */
@RestController
@RequestMapping("/push")
public class PushController {
    @Autowired
    SenderActivity senderActivity;

    @GetMapping("/msg")
    public String pusMsg(String cid, String title, String content) {
        SendRequest sendRequest = SendRequest.builder()
                .cid(cid)
                .messageParam(MessageParam.builder()
                        .title(title)
                        .body(content)
                        .build())
                .build();

        // 个推
        senderActivity.singleMsg(PushSender.PushSenderEnum.GE_TUI, sendRequest);

        return "ok";
    }
}
